package com.bolt.report.engine.calculator;

import com.bolt.common.utils.StrUtil;
import com.bolt.report.engine.BindData;
import com.bolt.report.engine.Calculator;
import com.bolt.report.engine.fill.FillContext;
import com.bolt.report.engine.model.Cell;
import com.bolt.report.engine.model.Expression.CalculatorExpression;

public class FormatNumberCalculator implements Calculator {
    private final String defaultPattern = "###.00";

    @Override
    public Object evaluate(FillContext context, BindData data, CalculatorExpression expr, Cell cell) {

//        if ((!data.isMultiple())) {
//            Object value = data.getData();
//            BigDecimal number = ToolUtil.toBigDecimal(value);
//            if (ArrayUtil.isNotEmpty(expr.getArgs())) {
//                DecimalFormat df = new DecimalFormat(expr.getArgs()[0]);
//                df.setRoundingMode(RoundingMode.HALF_UP);
//                return df.format(number.doubleValue());
//            } else {
//                DecimalFormat df = new DecimalFormat(defaultPattern);
//                df.setRoundingMode(RoundingMode.HALF_UP);
//                return df.format(number.doubleValue());
//            }
//        }
        return StrUtil.EMPTY;
    }
}